import { Sequelize } from 'sequelize-typescript'
import { MYSQL_CONF } from '../config/db'
import useModels from './models'
const { database, host, password, username } = MYSQL_CONF
const seq = new Sequelize({
  dialect: 'mysql',
  username,
  database,
  host,
  password,
  //经过多次测试models:[path]会出问题不能成功同步模型，所以采用批量注册模型
  dialectOptions: {
    dateStrings: true,
    typeCast: true
  },
  timezone: '+08:00'
})
//采用批量自动注册模型
useModels(seq)

export default seq
